#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    string s;
    while (n--)
    {
        cin >> s;
        int len = s.size() - 2;
        if (len < 8) cout << s << endl;
        else cout << s[0] << len << s[len + 1] << endl;
    }
    return 0;
}

string replaceSpaces(string S, int length) {
    string ret;
    for (int i = 0; i < length; i++)
    {
        if (S[i] != ' ')
            ret += S[i];
        else
            ret += "%20";
    }
    return ret;
}

struct ListNode {
    int val;
    ListNode* next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode* next) : val(x), next(next) {}
    
};

ListNode* swapPairs(ListNode* head) {
    if (head == nullptr || head->next == nullptr)
        return head;
    ListNode* tmp = swapPairs(head->next->next);
    ListNode* ret = head->next;
    head->next->next = head;
    head->next = tmp;
    return ret;
}

vector<vector<int>> fourSum(vector<int>& nums, int target) {
    sort(nums.begin(), nums.end());
    int n = nums.size();
    vector<vector<int>> vv;
    for (int i = 0; i < n - 2;)
    {
        if (target < 0 && nums[i]>0)
            break;
        for (int j = i + 1; j < n - 1;)
        {
            long long x = (long long)target - nums[i] - nums[j];
            int left = j + 1, right = n - 1;
            while (left < right)
            {
                int sum = nums[left] + nums[right];
                if (sum < x)
                    ++left;
                else if (sum > x)
                    --right;
                else
                {
                    vv.push_back({ nums[i],nums[j],nums[left],nums[right] });
                    ++left, --right;
                    while (left < right && nums[left] == nums[left - 1]) ++left;
                    while (left < right && nums[right] == nums[right + 1]) --right;
                }
            }
            ++j;
            while (j < n - 1 && nums[j] == nums[j - 1]) ++j;
        }
        ++i;
        while (i < n - 2 && nums[i] == nums[i - 1]) ++i;
    }
    return vv;
}